// pages/toast/toast.js
Page({
  handleShowToast() {
    wx.showToast({
      title: '你好啊,哈哈哈哈',
    })
  },
  handleShowToast2() {
    wx.showToast({
      title: '成功',
      icon: 'success',
      duration: 500,
      icon: 'loading',
      mask: true,
      success: () => {
        console.log("showToast2 success");
        wx.hideToast()
      }
    })
  },
  handleShowModal() {
    wx.showModal({
      title: '你好啊',
      content: '哈哈哈',
      showCancel: true,
      cancelText: '取消',
      cancelColor: '#000000',
      confirmText: '确定',
      confirmColor: '#3CC51F',
      success: (result) => {
        if(result.confirm){
          console.log('对哦');
        } 
        if(result.cancel) {
          console.log('取消啦');
        }
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },
  handleShowLoading() {
    wx.showLoading({
      title: '加载中',
      mask: true,
    })
    setTimeout(function () {
      //必须手动hideLoaing
      wx.hideLoading()
    }, 1000)
  },
  handleActionSheet() {
    wx.showActionSheet({
      itemList: ['相册', '拍照'],
      itemColor: '#000000',
      success: (result)=>{
        console.log(result);

        switch (result.tapIndex) {
          case 0:
            
            break;
          case 1:
            
            break;
          default:
            break;
        }
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },
  enableAlertBeforeUnload() {
    wx.enableAlertBeforeUnload({
      message: "哈哈哈?",
      success(res) {
        console.log(res);
      }
    })
  },
  disableAlertBeforeUnload() {
    wx.disableAlertBeforeUnload({
      success(res) {
        console.log(res);
      }
    })
  },
  onShareAppMessage(options) {
    return {
      title: 'Hello Lin.',
      path: '/pages/swiper/swiper',
      // path: '/pages/index/index',
      imageUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1590592186298&di=d57bfd9af359d19796c5c8abff956448&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20161215%2F20161215154634_940b4d487aedf8f5c0931f7f3591781b_1.jpeg'
    
    }
  },
  handleShare() {
    console.log(222);
    //测试后发现没有用 需要再百度
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
  },
  onLoad(){
    console.log(3333);
    //测试后发现没有用 需要再百度
    wx.showShareMenu({
      withShareTicket: true
    })
  },
})